package com.xia.qianke.controller;

import com.xia.qianke.entity.client.ApplyMsg;
import com.xia.qianke.entity.client.Client;
import com.xia.qianke.entity.qk.user.Sckd;
import com.xia.qianke.utils.DataUtils;
import com.xia.qianke.utils.HttpUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.thymeleaf.util.StringUtils;

/**
 * @ClassName TestController
 * @Description TODO
 * @Author XJY
 * @Date 2022/7/27 22:56
 * @Version 1.0
 **/
@RestController
public class TestController {
    @Autowired
    HttpUtils httpUtils;
    @Autowired
    DataUtils dataUtils;

    @PostMapping("/sckd")
    public Sckd getSckd(@RequestBody Client client){
        Sckd sckd = dataUtils.changeData (client);
        return sckd;
    }

    @PostMapping("/test")
    public ApplyMsg test(Client client){
        if(client != null && !StringUtils.isEmpty (client.getName ()) && !StringUtils.isEmpty (client.getPhone ())){
            //存入本地数据库
//            qk.addClient (client);
            //发送给仟客端
            httpUtils.postData (client);
            return new ApplyMsg ("0000","接收成功");
        }
        return new ApplyMsg ("1000","必要数据为空");
    }
}
